/* pts0DPlayerPositionAndLook.cpp
 *
 * --
 * Copyright (c) 2012, Christophe Huriaux
 * Distributed under the terms of the MIT license.
 * http://www.opensource.org/licenses/mit-license.php
 * --
 */

#include <packet/pts0DPlayerPositionAndLook.h>
#include <wrapper/JavaStreamWrapper.h>

pts0DPlayerPositionAndLook::pts0DPlayerPositionAndLook()
    : McPacketToServer(0x0D), x(.0), y(.0), stance(.0), z(.0), yaw(.0), pitch(.0), onGround(false)
{
}

pts0DPlayerPositionAndLook::pts0DPlayerPositionAndLook(double x, double y, double stance, double z, float yaw, float pitch, bool onGround)
    : McPacketToServer(0x0D), x(x), y(y), stance(stance), z(z), yaw(yaw), pitch(pitch), onGround(onGround)
{
}

unsigned int pts0DPlayerPositionAndLook::length()
{
    return 1 + 8 + 8 + 8 + 8 + 4 + 4 + 1;
}

void pts0DPlayerPositionAndLook::forge(std::ostream& out)
{
    JavaStreamWrapper jsw(out);

    jsw.writeByte(getPacketId());
    jsw.writeDouble(x);
    jsw.writeDouble(y);
    jsw.writeDouble(stance);
    jsw.writeDouble(z);
    jsw.writeFloat(yaw);
    jsw.writeFloat(pitch);
    jsw.writeBoolean(onGround);

}

double pts0DPlayerPositionAndLook::getX()
{
    return x;
}

double pts0DPlayerPositionAndLook::getY()
{
    return y;
}

double pts0DPlayerPositionAndLook::getStance()
{
    return stance;
}

double pts0DPlayerPositionAndLook::getZ()
{
    return z;
}

float pts0DPlayerPositionAndLook::getYaw()
{
    return yaw;
}

float pts0DPlayerPositionAndLook::getPitch()
{
    return pitch;
}

bool pts0DPlayerPositionAndLook::getOnGround()
{
    return onGround;
}


void pts0DPlayerPositionAndLook::setX(double x)
{
    this->x = x;
}

void pts0DPlayerPositionAndLook::setY(double y)
{
    this->y = y;
}

void pts0DPlayerPositionAndLook::setStance(double stance)
{
    this->stance = stance;
}

void pts0DPlayerPositionAndLook::setZ(double z)
{
    this->z = z;
}

void pts0DPlayerPositionAndLook::setYaw(float yaw)
{
    this->yaw = yaw;
}

void pts0DPlayerPositionAndLook::setPitch(float pitch)
{
    this->pitch = pitch;
}

void pts0DPlayerPositionAndLook::setOnGround(bool onGround)
{
    this->onGround = onGround;
}


